﻿using System.Collections.Generic;
using OnTheWay.Models;

namespace OnTheWay.Interfaces
{
    /// <summary>
    /// 在途人C#开发对象基本行为定义
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="TId"></typeparam>
    public interface IObjectBasicBehaviors<T, TId>
    {
        /// <summary>
        /// 插入操作
        /// </summary>
        /// <param name="model">对象</param>
        /// <returns>插入成功,则返回true,否则返回false</returns>
        bool Insert(T model);

        /// <summary>
        /// 修改操作
        /// </summary>
        /// <param name="model">对象</param>
        /// <returns>修改成功,则返回true,否则返回false</returns>
        bool Update(T model);

        /// <summary>
        /// 删除操作
        /// </summary>
        /// <param name="model">对象</param>
        /// <returns>删除成功,则返回true,否则返回false</returns>
        bool Delete(T model);

        /// <summary>
        /// 根据ID获取对象
        /// </summary>
        /// <param name="id">实例ID</param>
        /// <returns>符合条件的对象</returns>
        T GetByID(TId id);

        /// <summary>
        /// 更新对象列表
        /// </summary>
        /// <param name="list">待更新对象列表</param>
        /// <returns>更新成功,则返回true,否则返回false</returns>
        bool UpdateList(IList<T> list);

        /// <summary>
        /// 在数据库中查询是否存在该ID对应的对象
        /// </summary>
        /// <param name="id">待查询ID</param>
        /// <returns>存在,则返回true,否则返回false</returns>
        bool Exists(TId id);

        /// <param name="list">待删除对象列表</param>
        /// <summary>
        /// 删除对象列表
        /// </summary>
        /// <param name="list">待删除对象列表</param>
        /// <returns></returns>
        bool DeleteList(IList<T> list);

        /// <summary>
        /// 根据id列表对象
        /// </summary>
        /// <param name="id">待删除对象的ID</param>
        /// <returns>删除成功,则返回true,否则返回false</returns>
        bool DeleteByID(TId id);

        /// <summary>
        /// 获取满足指定条件的对象数目
        /// </summary>
        /// <param name="where">筛选条件</param>
        /// <returns>满足指定条件的对象数目</returns>
        long GetRecordCount(string where);

        /// <summary>
        /// 以分页形式获取满足指定条件的对象列表
        /// </summary>
        /// <param name="page">分页信息</param>
        /// <returns>满足指定条件的对象列表</returns>
        IList<T> GetListByPage(string where, Page page);

        /// <summary>
        /// 获取满足指定条件的对象列表
        /// </summary>
        /// <param name="where">筛选条件</param>
        /// <param name="order">排序字段</param>
        /// <param name="asc">asc升序排列,desc降序排列</param>
        /// <returns>满足指定条件的对象列表</returns>
        IList<T> GetListWhere(string where, string order, string asc);

        /// <summary>
        /// 获取无效数据
        /// </summary>
        /// <returns>满足指定条件的数据列表</returns>
        IList<T> GetInValidData();
        /// <summary>
        /// 以分页形式获取无效数据
        /// </summary>
        /// <param name="page">分页信息</param>
        /// <returns>满足指定条件的数据列表</returns>
        IList<T> GetInValidDataPage(Page page);
    }
}
